Skip to content

INTPYTHON-574 Use persistent connections by default #285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

timgraham
Copy link
Collaborator

@timgraham timgraham commented Apr 11, 2025

After implementing this, I noticed a documentation note that persistent connections as implemented in Django aren't compatible with ASGI. https://code.djangoproject.com/ticket/33497#comment:51 I'm not sure if that's a concern for this library.

On the other hand, Django's documentation suggests to use connection pooling with ASGI, and I think we need to change this library to support that (i.e. not initialize a new MongoClient in every get_new_connection() call.

@Jibola
Copy link
Contributor

Jibola commented Apr 17, 2025

https://code.djangoproject.com/ticket/33497#comment:51

IIRC so long as we're leveraging the same MongoClient, we are already maintaining an underlying connection pool. cc: @ShaneHarvey for confirmation.

@ShaneHarvey
Copy link
Member

I don't think ASGI is a concern. See my comment in https://jira.mongodb.org/browse/INTPYTHON-574. Do we test that setup?

@ShaneHarvey ShaneHarvey changed the title Use persistent connections by default INTPYTHON-574 Use persistent connections by default Apr 17, 2025
@timgraham
Copy link
Collaborator Author

I don't have much experience with ASGI/async, and I don't think the tests would catch a problem. Django has no tests for persistent connections which is why f5dbacb went undetected in initial development). If tests were added for ticket #33497, they would be expected failures on other backends. I'm going to have to investigate this in more detail to have any confidence that it works as expected which is why this PR is in draft status.

@timgraham
Copy link
Collaborator Author

timgraham commented Apr 18, 2025

I think this approach will be superseded by #290 (which is still in progress).

@timgraham timgraham closed this Apr 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants